package Demo1;

import java.util.Arrays;
import java.util.PriorityQueue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-07-22
 * Time: 13:48
 */
class Student{
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
}
public class Test {
    public static void main(String[] args) {
        Student student1 = new Student("hao",12);
        Student student2 = new Student("hello",19);
        PriorityQueue<Student> heap = new PriorityQueue<>();
        heap.offer(student1);//默认小根堆存储
        heap.offer(student2);
    }
    public static void main4(String[] args) {
        PriorityQueue<Integer> heap = new PriorityQueue<>();
        heap.offer(1);//默认小根堆存储
        heap.offer(2);
        heap.offer(3);
        System.out.println(heap);

    }
    public static void main3(String[] args) {
        int[] array = {12,33,54,72,34,19,27,38,16,30};
        TestHeap heap = new TestHeap();
        heap.initElem(array);
        heap.createHeap();
        System.out.println("排序前：" + heap.toString());
        heap.heapSort();
        System.out.println("排序后：" + heap.toString());
    }
    public static void main2(String[] args) {
        TestHeap heap = new TestHeap();
        heap.offer(1);
        heap.offer(2);
        heap.offer(3);
        heap.offer(4);
        heap.offer(5);
        heap.offer(6);
        heap.offer(7);
        System.out.println(heap.toString());
        heap.poll();
        heap.poll();
        heap.poll();
        heap.poll();
        System.out.println(heap.toString());
    }
    public static void main1(String[] args) {
        int[] array = {12,33,54,72,34,19,27,38,16,30};
        TestHeap heap = new TestHeap();
        heap.initElem(array);
        System.out.println(Arrays.toString(heap.elem));
        heap.createHeap();
        System.out.println(Arrays.toString(heap.elem));
    }
}
